#include <stdio.h>
#include <stdlib.h>

int
main(void)
{
	int AM[100][100];
	register int i=0, j=0;
	int n;

	freopen("check.in", "r", stdin);
	freopen("check.out", "w", stdout);
	scanf("%d", &n);
	while (i < n) {
		j = 0;
		while (j < n) {
			scanf("%d", &AM[i][j++]);
		}
		i++;
	}
	i=j=0;
	while (i < n) {
		j = i;
		while (j < n) {
			if (AM[i][j] != AM[j][i] ||
			    ( i == j && AM[i][i] )) {
				printf("NO\n");
				return 0;
			}
			j++;
		}
		i++;
	}
	printf("YES\n");
	return 0;
}
